package com.boot2.core.conf.mqtt;

import com.boot2.core.dao.datasource.DynamicDatasourceAop;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author zhangweilin
 * @Description: 动态数据源复杂点的条件
 * @date 2020/12/12
 */
public class DynamicDatasourceAopCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        boolean isHasDynamicDatasourceAop = context.getRegistry().containsBeanDefinition(DynamicDatasourceAop.instanceName);
//        System.out.println("isHasDynamicDatasourceAop = " + isHasDynamicDatasourceAop);
        return !isHasDynamicDatasourceAop;
    }
}
